﻿using System;
using System.ComponentModel;
using System.Data;
namespace WPFExcelReport
{
    public partial class TSTKM03
    {
      
         
        public double YQty
        {
            get
            {
                return Convert.ToDouble(txtYQty.Text.ToString());
            }
            set
            {
                txtYQty.Text = value.ToString();
            }
        }
        public TSTKM03()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_STOCKM();
            this.DataContext = MV;
            InitializeComponent(); 
          
        }
        
        public override void OnMKEYChg(DataRowView dwMKey)
        {
           
            if (dwMKey == null)
                return;

            string ART, VAR, FARBE, SPPART, ZWPART, FBPART, LO, LB, MDATE;
            DataTable tb;
            ART = dwMKey["ART"].ToString();
            VAR = dwMKey["VAR"].ToString();
            FARBE = dwMKey["FARBE"].ToString();
            LO = dwMKey["LO"].ToString();
            LB = dwMKey["LB"].ToString();
            SPPART = dwMKey["SPPART"].ToString();
            ZWPART = dwMKey["ZWPART"].ToString();
            FBPART = dwMKey["FBPART"].ToString();
            MDATE = dwMKey["MDATE"].ToString();
            filter = "ART='" + ART + "' AND VAR='" + VAR + "' AND FARBE='" + FARBE + "' AND LO='" + LO + "' AND LB='" + LB + "' AND MDATE='" + MDATE + "'";
            rows =TBMain.Select(filter);
            if (rows.Length > 0)
            {
                tb = rows.CopyToDataTable();
                tb.TableName=TB;
                if (vm.SetProd.Tables.Contains(TB))
                {
                    vm.SetProd.Tables[TB].Clear();
                }
                vm.SetProd.Merge(tb);
                YQty = 0;
                foreach (DataRow row in tb.Rows)
                {
                    YQty += Convert.ToDouble(row["STOCKQTY"].ToString());
                }
            } 
            if (vwMaster.View != null)
            {
                vwMaster.View.MoveCurrentToFirst();
            }
        } 
    }
}
